'''
媒体库收藏接口
'''

import allure
import requests
import conftest
from common.logger import Log

@allure.feature('媒体库模块')
class Test_getMedia():

    def setup_method(self):
        # 定义登录接口URL地址
        self.favoritedMedia_url = "http://192.168.3.182:9990/airservice-device/media/favoritedMedia"
        self.log = Log("媒体库收藏/取消收藏接口").get_logger()


    # case01 收藏媒体库
    #@allure.story('收藏媒体库')
    def test_favoritedMedia_case01(self):

        self.favoritedMedia_data ={
                                    "fileIdList": [
                                        729
                                    ],
                                    "favorited": 1
                                }

        response = requests.post(url=self.favoritedMedia_url, json=self.favoritedMedia_data, headers=conftest.headers_data)
        with allure.step(title="数据:{}".format(self.favoritedMedia_data)):
            pass

        #添加断言
        assert response.json().get("message") == "success"
        assert  response.json().get("success") == True

        self.log.info("{}".format(response.json()))

    # case02 取消收藏媒体库
    @allure.step(title="取消收藏")
    #@allure.story('取消收藏媒体库')
    def test_favoritedMedia_case02(self):

        self.favoritedMedia_data ={
                                    "fileIdList": [
                                        729
                                    ],
                                    "favorited": 0
                                }

        response = requests.post(url=self.favoritedMedia_url, json=self.favoritedMedia_data, headers=conftest.headers_data)

        #添加断言
        assert response.json().get("message") == "success"
        assert  response.json().get("success") == True

        self.log.info("{}".format(response.json()))

